﻿package model.entity.product;

import java.util.Map;
import java.util.Map.Entry;

import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name="TV")
public class TV extends Electronic {

	private String resolution;
	private String connection;
	private String technology;
	private String brigthness;
	public String getResolution() {
		return resolution;
	}
	public void setResolution(String resolution) {
		this.resolution = resolution;
	}
	public String getConnection() {
		return connection;
	}
	public void setConnection(String connection) {
		this.connection = connection;
	}
	public String getTechnology() {
		return technology;
	}
	public void setTechnology(String technology) {
		this.technology = technology;
	}
	public String getBrigthness() {
		return brigthness;
	}
	public void setBrigthness(String brigthness) {
		this.brigthness = brigthness;
	}
	@Override
	public String toString() {
		return "TV [resolution=" + resolution + ", connection=" + connection
				+ ", technology=" + technology + ", brigthness=" + brigthness
				+ ", size=" + size + ", warranty=" + warranty
				+ ", powerCosume=" + powerCosume + ", id=" + id + ", name="
				+ name + ", price=" + price + ", image=" + image
				+ ", quantity=" + quantity + ", extraInfo=" + extraInfo
				+ ", brand=" + brand + ", state=" + state + "]";
	}
	public static Map<String, Class<?>> fieldMap(){
		Map<String, Class<?>> fieldMap = Electronic.fieldMap();
		fieldMap.put("resolution", String.class);
		fieldMap.put("connection", String.class);
		fieldMap.put("technology", String.class);
		fieldMap.put("brigthness", String.class);
		return fieldMap;
	}
	
	@Override
	public void insertData(Map<String, Object> valueMap) {
		super.insertData(valueMap);
		for (Entry<String, Object> entry : valueMap.entrySet()) {
			Object value = entry.getValue();
			
			//Dk rong
			if(entry.getValue() == null) continue;
			
			switch (entry.getKey()) {
			case "resolution":
				this.resolution = (String) value;
				break;
			case "connection":
				this.connection = (String) value;
				break;
			case "technology":
				this.technology = (String) value;
				break;
			case "brigthness":
				this.brigthness = (String) value;
				break;
			default:
				break;
			}
		}
	}
}
